home *** CD-ROM | disk | FTP | other *** search
- Path: andrew.cmu.edu!bo24+
- From: Berend Ozceri <bo24+@andrew.cmu.edu>
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Messages vs. Semaphores for external clocking
- Date: Thu, 4 Apr 1996 15:38:38 -0500
- Organization: Masters student, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
- Distribution: world
- Message-ID: <slN3BCS00iWZ0_8G1R@andrew.cmu.edu>
- References: <4ju349$r1e@sparky.navsea.navy.mil>
- <4jvrqs$hk0@btmpjg.god.bel.alcatel.be>
- NNTP-Posting-Host: po2.andrew.cmu.edu
- In-Reply-To: <4jvrqs$hk0@btmpjg.god.bel.alcatel.be>
-
- Excerpts from netnews.comp.sys.amiga.programmer: 4-Apr-96 Re: Messages
- vs. Semaphores.. by @nlev00
- > >I am wondering what is the most efficient way for one task to make data
- > >available to another task. I can do this by passing messages, or by
- > >setting up a semaphore to provide a common area of memory accessible by
- > >both tasks.
- > >
- > [..description removed..]
- >
- > Use global data, which your subtask fills with the timer-values,
- > and the parent process reads. Disable() and Enable() multitasking
- > when performing such a critical action (reading or writing from the
- > global data). No message port or semaphore needed.
-
- This is very, very bad advice. A message port or a semaphore is indeed
- needed. Disable()/Enable() are bad programming styles, especially for
- user level programs because they disable multitasking. Using semaphores
- to protect critical sections is a much better solution. As a matter of
- fact, this is exactly the type of situation semaphores are there for.
-
- Berend Ozceri
- Carnegie Mellon University
-
-